<?php

add_action('init','of_options');

if (!function_exists('of_options'))
{
	function of_options()
	{
		//Access the WordPress Categories via an Array
		$of_categories 		= array();  
		$of_categories_obj 	= get_categories('hide_empty=0');
		foreach ($of_categories_obj as $of_cat) {
		    $of_categories[$of_cat->cat_ID] = $of_cat->cat_name;}
		$categories_tmp 	= $of_categories;
		array_unshift($of_categories, "Select a category:");    
	       
	       //Access all post
	        $of_post = array();
	        $args = array( 'posts_per_page' => -1); 
		$posts= get_posts( $args );
		foreach ($posts as $of_posted) {
		    $of_post[$of_posted->ID] = $of_posted->post_title; 
		    }
		$of_post_tmp = array_unshift($of_post, "Select a post:");  
		
		//Access the WordPress Pages via an Array
		$of_pages 			= array();
		$of_pages_obj 		= get_pages('parent=0,sort_column=post_parent,menu_order');    
		foreach ($of_pages_obj as $of_page) {
		    $of_pages[$of_page->ID] = $of_page->post_title; }
		    
		$of_pages_tmp = $of_pages;
		array_unshift($of_pages, "Select a page:");     
		//$of_pages_tmp 		= array_unshift($of_pages);       
	
		//Testing 
		$of_options_select 	= array("one","two","three","four","five"); 
		$of_options_radio 	= array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five");
		
		//Sample Homepage blocks for the layout manager (sorter)
		$of_options_homepage_blocks = array
		( 
			"disabled" => array (
				"placebo" 		=> "placebo", //REQUIRED!
				"block_one"		=> "Block One",
				"block_two"		=> "Block Two",
				"block_three"	=> "Block Three",
			), 
			"enabled" => array (
				"placebo" 		=> "placebo", //REQUIRED!
				"block_four"	=> "Block Four",
			),
		);


		//Stylesheets Reader
		$alt_stylesheet_path = LAYOUT_PATH;
		$alt_stylesheets = array();
		
		if ( is_dir($alt_stylesheet_path) ) 
		{
		    if ($alt_stylesheet_dir = opendir($alt_stylesheet_path) ) 
		    { 
		        while ( ($alt_stylesheet_file = readdir($alt_stylesheet_dir)) !== false ) 
		        {
		            if(stristr($alt_stylesheet_file, ".css") !== false)
		            {
		                $alt_stylesheets[] = $alt_stylesheet_file;
		            }
		        }    
		    }
		}


		//Background Images Reader
		$bg_images_path = get_stylesheet_directory(). '/images/bg/'; // change this to where you store your bg images
		$bg_images_url = get_template_directory_uri().'/images/bg/'; // change this to where you store your bg images
		$bg_images = array();
		
		if ( is_dir($bg_images_path) ) {
		    if ($bg_images_dir = opendir($bg_images_path) ) { 
		        while ( ($bg_images_file = readdir($bg_images_dir)) !== false ) {
		            if(stristr($bg_images_file, ".png") !== false || stristr($bg_images_file, ".jpg") !== false) {
		                $bg_images[] = $bg_images_url . $bg_images_file;
		            }
		        }    
		    }
		}
		

		/*-----------------------------------------------------------------------------------*/
		/* TO DO: Add options/functions that use these */
		/*-----------------------------------------------------------------------------------*/
		
		//More Options
		$uploads_arr 		= wp_upload_dir();
		$all_uploads_path 	= $uploads_arr['path'];
		$all_uploads 		= get_option('of_uploads');
		$other_entries 		= array("Select a number:","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");
		$body_repeat 		= array("no-repeat","repeat-x","repeat-y","repeat");
		$body_pos 			= array("top left","top center","top right","center left","center center","center right","bottom left","bottom center","bottom right");
		
		// Image Alignment radio box
		$of_options_thumb_align = array("alignleft" => "Left","alignright" => "Right","aligncenter" => "Center"); 
		
		// Image Links to Options
		$of_options_image_link_to = array("image" => "The Image","post" => "The Post"); 

		$wp_editor_settings = array(
			'wpautop' => true, // Default
			'textarea_rows' => 5,
			'tinymce' => array( 'plugins' => 'wordpress' )
		);

/*-----------------------------------------------------------------------------------*/
/* The Options Array */
/*-----------------------------------------------------------------------------------*/

// Set the Options Array
global $of_options;
$of_options = array();

$of_options[] = array( 	"name" 		=> "Home Settings",
						"type" 		=> "heading"
				);

						
$of_options[] = array( 	"name" 		=> "Logo",
						"desc" 		=> "To change the your logo, you can upload the image/",
						"id" 		=> "logo_url",
						// Use the shortcodes [site_url] or [site_url_secure] for setting default URLs
						"std" 		=> "http://project.wedangsusu.com/ttb/wp-content/uploads/2013/08/logo.png",
						"type" 		=> "media"
				);
				

$of_options[] = array( 	"name" 		=> "Character Count",
						"desc" 		=> "You can set character count to display in Welcome Messages.",
						"id" 		=> "count_welcome",
						"std" 		=> "400",
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Recent Post",
						"desc" 		=> "You can set how many recent post will be display in Sidebar",
						"id" 		=> "recent_count",
						"std" 		=> "1",
						"type" 		=> "text"
				);	
$of_options[] = array( 	"name" 		=> "Display Address",
						"desc" 		=> "Set ON if you want to display address in your footer",
						"id" 		=> "switch_slider",
						"std" 		=> 0,
						"folds"		=> 1,
						"type" 		=> "switch"
				);								

$of_options[] = array( 	"name" 		=> "Address",
						"desc" 		=> "You can change the address in your homepage in here.",
						"id" 		=> "address",
						"std" 		=> "3015 Grand Ave, Coconut Grove, Merrick Way, FL 12345",
						"fold" 		=> "switch_slider",
						"type" 		=> "textarea"
				);	

$of_options[] = array( 	"name" 		=> "Phone Number",
						"desc" 		=> "You can change the phone number in your homepage in here.",
						"id" 		=> "phone",
						"std" 		=> "123-456-7890",
						"type" 		=> "text"
				);																	

$of_options[] = array( 	"name" 		=> "Email",
						"desc" 		=> "You can change the email account in your homepage in here.",
						"id" 		=> "email",
						"std" 		=> "admin@woodranch-experts.com",
						"type" 		=> "text"
				);
								
$of_options[] = array( 	"name" 		=> "Footer Text",
						"desc" 		=> "You can change the title footer in here.",
						"id" 		=> "footer_text",
						"std" 		=> "© 2013 KEYSON GROUP",
						"type" 		=> "text"
				);	

$of_options[] = array( 	"name" 		=> "Social Media",
						"type" 		=> "heading",
						"icon"		=> ADMIN_IMAGES . "icon-docs.png"
				);

$of_options[] = array( 	"name" 		=> "Facebook",
						"desc" 		=> "Insert your facebook link",
						"id" 		=> "text_facebook",
						"std" 		=> "",
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Twitter",
						"desc" 		=> "Insert your twitter account link",
						"id" 		=> "text_twitter",
						"std" 		=> "",
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "LinkedIn",
						"desc" 		=> "Insert your linkedin profile link",
						"id" 		=> "text_linkedin",
						"std" 		=> "",
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Google Plus",
						"desc" 		=> "Insert your google plus link",
						"id" 		=> "text_google",
						"std" 		=> "",
						"type" 		=> "text"
				);
				
/*$of_options[] = array( 	"name" 		=> "Select Multiple Page",
						"desc" 		=> "In this part you can select page for display in catering sidebar",
						"id" 		=> "page_accordion",
						"type" 		=> "multicheck",
						"options" 	=> $of_pages_tmp
				);*/				
				

/*$of_options[] = array( 	"name" 		=> "Slider Setting",
						"type" 		=> "heading",
						"icon"		=> ADMIN_IMAGES . "icon-slider.png"
				);
				
$of_options[] = array( 	"name" 		=> "Slider Options",
						"desc" 		=> "If you want to re order the slider, please input the order position field",
						"id" 		=> "home_slider",
						"std" 		=> "",
						"type" 		=> "slider"
				);



$of_options[] = array( 	"name" 		=> "Social",
						"desc" 		=> "You can add multiple social media. Upload the logo and insert the link for the social media.",
						"id" 		=> "social",
						"std" 		=> "",
						"type" 		=> "banner_slider"
				);
$of_options[] = array( 	"name" 		=> "Our Partner",
						"type" 		=> "heading",
						"icon"		=> ADMIN_IMAGES . "icon-slider.png"
				);
$of_options[] = array( 	"name" 		=> "Partner",
						"desc" 		=> "You can add your partner",
						"id" 		=> "partner",
						"std" 		=> "",
						"type" 		=> "banner_slider"
				);*/								
	}//End function: of_options()
}//End chack if function exists: of_options()
?>